package com.training.java.core.collections.car.post15;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class FruitsTreeSetDemo {

	public static void main(String[] args) {
		// public static void main(String[] args) {
		// Instantiating multiple objects Fruit1, Fruit2,Fruit3,Fruit4

		Fruit fruit1 = new Fruit("Custard Apple", "Green", "Sweet", 1);
		Fruit fruit2 = new Fruit(" Apple", "Green", "Sweet", 2);
		Fruit fruit3 = new Fruit("Banana", "Yellow", "Sweet", 4);
		Fruit fruit4 = new Fruit("Mango", "Yellow", "Sweet", 30);
		Fruit fruit5 = new Fruit("Persimon", "Orange", "Sweet", 5);
		Fruit fruit6 = new Fruit("Custard Apple", "Green", "Sweet", 1);

		// Creating a collection using the set

		Set<Fruit> listOfFruits = new TreeSet<Fruit>();

		// adding the objects to the container/List
		listOfFruits.add(fruit1);
		listOfFruits.add(fruit2);
		listOfFruits.add(fruit3);
		listOfFruits.add(fruit4);
		listOfFruits.add(fruit5);
		listOfFruits.add(fruit6);

		// for each loop, no need to type cast statement

		for (Fruit aFruit : listOfFruits) {
			// Printing the Fruits Information
			System.out.println("Name of the fruit:    " + aFruit.getName());
			System.out.println("Color of the fruit:   " + aFruit.getColor());
			System.out.println("Taste of the fruit:   " + aFruit.getTaste());
			System.out.println("Price of the fruit:   " + aFruit.getPrice());
			System.out.println("****************************");
		}
		// iterator for Fruits
		/*
		 * Iterator<Fruit> ite = listOfFruits.iterator(); while (ite.hasNext())
		 * { Fruit eFruit = (Fruit) ite.next();// Type casting Fruit
		 * 
		 * // Printing the Fruits Information
		 * System.out.println("Name of the fruit:    " + eFruit.getName());
		 * System.out.println("Color of the fruit:   " + eFruit.getColor());
		 * System.out.println("Taste of the fruit:   " + eFruit.getTaste());
		 * System.out.println("Price of the fruit:   " + eFruit.getPrice());
		 * System.out.println("****************************"); }
		 */
	}

}
